import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '姓名',
    align:"center",
    sorter: true,
    dataIndex: 'name'
  },
  {
    title: '所属承包商',
    align:"center",
    sorter: true,
    dataIndex: 'contractorId_dictText'
  },
  {
    title: '性别',
    align:"center",
    dataIndex: 'sex_dictText'
  },
  {
    title: '年龄',
    align:"center",
    dataIndex: 'age'
  },
  {
    title: '学历',
    align:"center",
    dataIndex: 'educationalBackground_dictText'
  },
  {
    title: '身份证号',
    align:"center",
    sorter: true,
    dataIndex: 'idCard'
  },
  {
    title: '岗位类型',
    align:"center",
    dataIndex: 'contractorPostType_dictText'
  },
  {
    title: '定位卡号',
    align:"center",
    dataIndex: 'locationCardNumber'
  },
  {
    title: '状态',
    align:"center",
    dataIndex: 'deleted_dictText'
  },
];

//列表数据
export const columnsPersonnelAndQualificationCertificate: BasicColumn[] = [
  {
    title: '姓名',
    align:"center",
    sorter: true,
    dataIndex: 'name'
  },
  {
    title: '所属承包商',
    align:"center",
    sorter: true,
    dataIndex: 'contractorId_dictText'
  },
  {
    title: '证书名称',
    align:"center",
    dataIndex: 'certificateName'
  },
  {
    title: '证书编号',
    align:"center",
    dataIndex: 'number'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "姓名",
    field: "name",
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "所属承包商",
    field: "contractorId",
    component: 'JSearchSelect',
    componentProps:{
      dict:"tb_contractor,name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "学历",
    field: "educationalBackground",
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"educationalBackground"
    },
    //colProps: {span: 6},
  },
  {
    label: "岗位类型",
    field: "contractorPostType",
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"contractorPostType"
    },
    //colProps: {span: 6},
  },
  {
    label: "状态",
    field: "deleted",
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"normalOrStop"
    },
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '姓名',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入姓名!'},
      ];
     },
  },
  {
    label: '所属承包商',
    field: 'contractorId',
    component: 'JSearchSelect',
    componentProps:{
      dict:"tb_contractor,name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入所属承包商!'},
      ];
     },
  },
  {
    label: '性别',
    field: 'sex',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"sex"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入性别!'},
      ];
     },
  },
  {
    label: '年龄',
    field: 'age',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入年龄!'},
      ];
     },
  },
  {
    label: '学历',
    field: 'educationalBackground',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"educationalBackground"
    },
  },
  {
    label: '身份证号',
    field: 'idCard',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入身份证号!'},
      ];
     },
  },
  {
    label: '岗位类型',
    field: 'contractorPostType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"contractorPostType"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入岗位类型!'},
      ];
     },
  },
  {
    label: '定位卡号',
    field: 'locationCardNumber',
    component: 'Input',
  },
  {
    label: '状态',
    field: 'deleted',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"normalOrStop"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入状态!'},
      ];
     },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
	field: 'id',
	component: 'Input',
	show: false
  },
];

//子表列表数据
export const tbContractorPersonnelQualificationCertificateColumns: BasicColumn[] = [
  {
    title: '工种/资质',
    align:"center",
    dataIndex: 'qualification_dictText'
  },
  {
    title: '证书名称',
    align:"center",
    dataIndex: 'name'
  },
  {
    title: '证书编号',
    align:"center",
    dataIndex: 'number'
  },
  {
    title: '开始日期',
    align:"center",
    dataIndex: 'startDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
  },
  {
    title: '结束日期',
    align:"center",
    dataIndex: 'endDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
  },
  {
    title: '附件',
    align:"center",
    dataIndex: 'doc',
  },
  {
    title: '状态',
    align:"center",
    dataIndex: 'deleted_dictText'
  },
];
//子表表单数据
export const tbContractorPersonnelQualificationCertificateFormSchema: FormSchema[] = [
  // TODO 子表隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
  {
    label: '工种/资质',
    field: 'qualification',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"jobTypeQualification"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入工种/资质!'},
      ];
    },
  },
  {
    label: '证书名称',
    field: 'name',
    component: 'Input',
  },
  {
    label: '证书编号',
    field: 'number',
    component: 'Input',
  },
  {
    label: '开始日期',
    field: 'startDate',
    component: 'DatePicker',
  },
  {
    label: '结束日期',
    field: 'endDate',
    component: 'DatePicker',
  },
  {
    label: '附件',
    field: 'doc',
    component: 'JUpload',
    componentProps:{
     },
  },
  {
    label: '状态',
    field: 'deleted',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"normalOrStop"
    },
  },
];

// 高级查询数据
export const superQuerySchema = {
  name: {title: '姓名',order: 0,view: 'text', type: 'string',},
  contractorId: {title: '所属承包商',order: 1,view: 'sel_search', type: 'string',dictTable: "tb_contractor", dictCode: 'id', dictText: 'name',},
  sex: {title: '性别',order: 2,view: 'radio', type: 'string',},
  age: {title: '年龄',order: 3,view: 'number', type: 'number',},
  educationalBackground: {title: '学历',order: 4,view: 'list', type: 'string',dictCode: 'educationalBackground',},
  idCard: {title: '身份证号',order: 5,view: 'text', type: 'string',},
  contractorPostType: {title: '岗位类型',order: 6,view: 'radio', type: 'string',},
  locationCardNumber: {title: '定位卡号',order: 7,view: 'text', type: 'string',},
  deleted: {title: '状态',order: 8,view: 'radio', type: 'string',},
};
